using System;
using System.Data;
using System.Data.SqlClient;
using Microsoft.SharePoint;

namespace MessageBoard
{
	/// <summary>
	/// Summary description for Connection.
	/// </summary>
	public class Connection
	{
		private static string _tblGroup = "MB_Group";
		private static string _tblCategory = "MB_Category";
		private static string _tblForum = "MB_Forum";
		private static string _tblThread = "MB_Thread";
		private static string _tblPost = "MB_Post";
		private static string _tblUser = "MB_User";
		private static string _tblUserGroup = "MB_UserGroup";
		private static string _tblUsersInGroups = "MB_UsersInGroups";
		private static string _tblRole = "MB_Role";
		private static string _tblLanguage = "MB_Language";
		private static string _tblCustomControl = "MB_CustomControl";
		private static string _tblTranslation = "MB_Translation";
		private readonly static string connectionString = System.Configuration.ConfigurationSettings.AppSettings["connectionString"];
        
		public Connection()
		{
			
		}

		#region Connection
		public static SqlConnection DbConnection
		{
			get
			{
				SqlConnection connection = (SqlConnection)System.Web.HttpContext.Current.Items["currentConnection"];
				if(connection == null)
				{
					connection = new SqlConnection(connectionString);
					System.Web.HttpContext.Current.Items["currentConnection"] = connection;
				}
				return connection;
			}
		}
		#endregion

		#region Properties
		public static string tblGroup
		{
			get
			{
				return _tblGroup;
			}
			set
			{
				_tblGroup = value;
			}
		}

		public static string tblCategory
		{
			get
			{
				return _tblCategory;
			}
			set
			{
				_tblCategory = value;
			}
		}

		public static string tblForum
		{
			get
			{
				return _tblForum;
			}
			set
			{
				_tblForum = value;
			}
		}

		public static string tblThread
		{
			get
			{
				return _tblThread;
			}
			set
			{
				_tblThread = value;
			}
		}

		public static string tblPost
		{
			get
			{
				return _tblPost;
			}
			set
			{
				_tblPost = value;
			}
		}

		public static string tblUser
		{
			get
			{
				return _tblUser;
			}
			set
			{
				_tblUser = value;
			}
		}

		public static string tblUserGroup
		{
			get
			{
				return _tblUserGroup;
			}
			set
			{
				_tblUserGroup = value;
			}
		}

		public static string tblUsersInGroups
		{
			get
			{
				return _tblUsersInGroups;
			}
			set
			{
				_tblUsersInGroups = value;
			}
		}

		public static string tblRole
		{
			get
			{
				return _tblRole;
			}
			set
			{
				_tblRole = value;
			}
		}

		public static string tblLanguage
		{
			get
			{
				return _tblLanguage;
			}
			set
			{
				_tblLanguage = value;
			}
		}

		public static string tblCustomControl
		{
			get
			{
				return _tblCustomControl;
			}
			set
			{
				_tblCustomControl = value;
			}
		}

		public static string tblTranslation
		{
			get
			{
				return _tblTranslation;
			}
			set
			{
				_tblTranslation = value;
			}
		}

		#endregion
	}
}
